{extend name="layout:default" /}

{block name="title"}评教管理{/block}

{block name="content"}
<link href="https://cdn.bootcss.com/layer/2.2/skin/layer.css" rel="stylesheet">
<div class="row">

    <div class="col-xs-12">

        <div class="box">

            <div class="box-header">

                <h3 class="box-title">评教列表</h3>

                <div class="box-tools">

                    <a href="{:url('add')}" class="btn btn-info"> 添加 </a>
                </div>

            </div>

            <!-- /.box-header -->

            <div class="box-body table-responsive no-padding">

                <table class="table table-hover">
                    <tbody>
                    <tr>
                        <th>序号</th>
                        <th>评教期数</th>
                        <th>是否禁用</th>
                        <th>评教时间</th>
                        <th>操作</th>
                    </tr>

                    {volist name="e" id="vo"}
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.title}</td>
                        <td><div class="switch" data-on-label="正常" data-off-label="禁用">
                            <input type="checkbox" onchange="status(this,{$vo.id})" {$vo.status == 1 ? 'checked': ''} />
                        </div>
                        </td>
                        <td>{:date('Y-m-d H:i:s',$vo.addtime)}</td>
                        <td>
                            <a href="{:url('/admin/eq/index', ['id'=>$vo.id])}" title="所有题目" class="btn btn-primary">所有题目</a>
                            <a href="{:url('logs', ['eid'=>$vo.id])}" title="评教情况" class="btn btn-warning">评教情况</a>
                            <a title="编辑" href="{:url('edit',['id'=>$vo.id])}" class="btn btn-success"><i
                                    class="glyphicon glyphicon-edit"></i></a>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>

                </table>
                {$e->render()}
            </div>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
</div>

{/block}

{block name="js"}

<script src="https://cdn.bootcss.com/layer/2.2/layer.js"></script>
<script>

    function status(obj, id) {
        let s = +($(obj).prop("checked"));
        /*if (s == 2) {
            $('input:checkbox').prop('checked', false);
            $(obj).prop('checked', true);
        }*/
        // console.log(s, id);
        layer.confirm('您确定要改变？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('/admin/evaluations/status', {id:id, status: s}, function (data) {
                if (data.status == 200) {
                    layer.msg(data.message, {icon: 1})
                } else {
                    layer.msg(data.message, {icon: 2})
                }
                setTimeout(function () {
                    window.location.href = window.location;
                }, 200)
            });
        }, function(){
            layer.close();
        });


    }
</script>
{/block}